﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using HKEA.CMS.Core;
using HKEA.CMS.Core.BLL;
using HKEA.CMS.Core.Models;
using System.Web.Script.Services;
using HKEA.CMS.Core.BLL.Tbl;

namespace WebApplication
{
    /// <summary>
    /// KeyWorldSearch 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]
    //[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public class KeyWorldSearch : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }


        
        public static string[] GetCustomerIDList(string prefixText)
        {
            tblCustomer entCustomer = new tblCustomer();
            tblCustomerBLL bllCustomer = new tblCustomerBLL();
            List<tblCustomer> listCustomer = bllCustomer.GetListByENT(entCustomer);
            var Customer = listCustomer.Select(p => p.CustomerID).Where(p => p.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase)).Take(10).ToArray();
            return Customer;
        }


        //[WebMethod]
        

        [WebMethod]
        public string[] WebServerTest(string prefixText)
        {
            string[] movies = {"比亞聯合有限公司" ,"立基洋行有限公司","蒙地奧香港有限公司","黛安芬國際海外有限公司香港分公司 ","恒生銀行","渣打銀行(香港)有限公司", "Shrek", "Shrek II" };
            return (from m in movies where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase) select m).Take(10).ToArray(); 
        }
    }
    
}
